<?php
/**
 * @category Goatherd
 * @package Goatherd\Commons
 *
 * @author Copyright (c) 2012 Maik Penz <maik@phpkuh.de>
 * @version $Id: ITree.php 105 2012-06-15 11:00:45Z maik@phpkuh.de $
 *
 * This file is part of Goatherd library.
 *
 * Goatherd library is free software: you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * Goatherd library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with Goatherd library. If not, see <http://www.gnu.org/licenses/>.
 */
namespace Goatherd\Commons\Word;

/**
 * Abstract tree interface.
 *
 * @package Goatherd\Commons
 * @subpackage Word
 */
interface ITree
{
    /**#@+
     * @var int
     */
    const NODE_DATA = 0;
    const NODE_CHILDREN = 1;
    /**#@-*/

    /**
     *
     * @param array $path
     * @param mixed $data
     *
     * @return \Goatherd\Commons\Word\ITree - fluent interface
     */
    public function set(array &$path, $data);

    /**
     *
     * @param array $path
     * @return mixed - data or NULL on error
     */
    public function &get(array &$path);

    /**
     *
     * @param array $path
     * @return boolean - node is leaf
     */
    public function isLeaf(array &$path);

    /**
     * Get root reference.
     *
     * @return array
     */
    public function &getRoot();

    /**
     * Override root.
     *
     * @param array $node
     * @return \Goatherd\Commons\Word\ITree - fluent interface
     */
    public function setRoot(array &$node);
}